# Maintainer: Frederik Carlier <frederik.carlier@keysight.com>

_realname=tools-xctest
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.1.1
pkgrel=2
pkgdesc="Testing framework for Objective-C, providing functionalities identical to Apple's XCTest (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://gnustep.github.io/'
msys2_repository_url='https://github.com/gnustep/tools-xctest'
license=('spdx:LGPL-2.1-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-gnustep-base")
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-clang"
             "${MINGW_PACKAGE_PREFIX}-lld"
             "${MINGW_PACKAGE_PREFIX}-gnustep-make"
             rsync)
source=("${msys2_repository_url}/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('d72d9a32cb271746f0058379ff81e593dd7e6fb3d1686d7dabe8ec986b3571ae')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
}

build() {
  rsync --recursive --times --links "${srcdir}/${_realname}-${pkgver}"/* "${srcdir}/build-${MSYSTEM}"
  cd "${srcdir}/build-${MSYSTEM}"

  CC="$MINGW_PREFIX/bin/clang" \
  CXX="$MINGW_PREFIX/bin/clang++" \
  make
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make install DESTDIR="${pkgdir}"

  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/COPYING.LIB \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/gnustep-xctest/COPYING.LIB
}
